home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 109
/
Vol 109.iso
/
games
/
bubble_t.swf
/
scripts
/
frame_1
/
DoAction.as
< prev
Wrap
Text File
|
2008-11-12
|
28KB
|
1,175 lines
function init()
{
gDebug = false;
gSticky = {val:1};
gMoveGun = {val:0};
gAutomatic = {val:0};
gRandomLevels = {val:0};
gUseKeyboard = {val:1};
gHighScoreEligible = {val:1};
gOption = [gSticky,gMoveGun,gAutomatic,gRandomLevels,gUseKeyboard,gHighScoreEligible];
gDefaultOption = [gSticky.val,gMoveGun.val,gAutomatic.val,gRandomLevels.val,gUseKeyboard.val,gHighScoreEligible.val];
var i = 0;
while(i < gOption.length)
{
_root["option_" + i].gotoAndStop(gOption[i].val + 1);
_root["option_" + i].pID = i;
gOption[i].pID = i;
i++;
}
gGunDir = 1;
gGunSpeed = 25;
gBombFrame = 6;
gBombRadius = 2;
gLevel = 1;
score = 0;
scorecheck = "0";
cNORMAL = 1;
cFIRE = 2;
cCONTACT = 3;
cREMOVE = 4;
cDEBUG = 5;
cCEILING = 6;
cSTART = 7;
cMOVE = 8;
cFINISH = 9;
cSTARTGAME = 10;
cSTARTLEVEL = 11;
gMode = cSTARTGAME;
gLevelData = new Array();
gLevelData.push(" ");
gLevelData.push("112233D332211.3311224221133");
gLevelData.push("1122322322111.40233F3320444.1100100100111");
gLevelData.push("I11444E11444I.2233223322332.1144411144411");
gLevelData.push("0023344433200.002K0440K2000.0020004000200.0124000042100.0114400044110");
gLevelData.push("3D212434212D2.3420243420242.4341014341014.1300001300001.00100000M0000");
gLevelData.push("4221322432213.4214324232143.4001300430013.000D000A000D0.0002200220022");
gLevelData.push("01101E0E10110.0300300300300.02B0440220D40.0300300300300.0110110110110.0300300300300.0440220440220");
gLevelData.push("104330O033401.1043033034010.01040E2E04010.0104000040100.0030000000300.0300000000300.0300000000030");
gLevelData.push("02244C44C4422.2421014101242.0B2100220012B.030000J000030.0220000000022.4340000000434");
gLevelData.push("1O201020102O1.1023A020A3201.1020132310201.1020102010201.4324332443243.03400DC003400");
gLevelData.push("1123201102321.12K201A102O21.0002300003200.0004310134000.0003400004300.0034000004300.0000300003000.0000C000C0000");
gLevelData.push("0120430210340.F01304M0240G0.0300400200100.3304402201100.010A20D30B400.0010040020000.0001003002000");
gLevelData.push("0040J3443J040.D40223432204D.0340030030043.301101A101103.0000030030000");
gLevelData.push("22A03322330A2.010211P112010.0102034430201.2000340430002.0231010010132.0F100000001F0.0010000000010");
gLevelData.push("0131141411310.010H0110H0100.02FC42224CF20.0030033003000.0302214122030.0310100101300");
gLevelData.push("00422H3H23322.040404040L040.0A14001A04040.010A10101A011.03C0104D01001.0003C0004D033");
gLevelData.push("3K323K323K323.2112112112112.4343434343434.0400040040004.00D000404000D.0400040040004");
gLevelData.push("2300340013004.4G111H222G111.0032004100340.E123G312F2411.0420021001400.0400020001000.0040002000100");
gLevelData.push("033130301M031.A13L11334313G.0341034113141.031331C303031.0302001030113.0202020200202.02000B00B0200");
gLevelData.push("1I1443G3221I1.114H4332F2110.2323121434324.1414343212131");
if(gDebug)
{
gLevelData = [" "];
gLevelData.push("112233D332211.3311224221133");
}
gSpacing = 20;
gRdX = (- gSpacing) / 2;
gRdY = gSpacing * 1.7320508075688774 / 2;
gCdX = gSpacing;
gCdY = 0;
gGunLength = 53;
gProjectileSpeed = 300;
gDieDuration = 0;
gNumTypes = 4;
gNumRecentTypes = 3;
gFrameTimer = -1;
gMaxSquash = 0.4;
gMinSpacing = gSpacing * (1 - gMaxSquash) / 2;
gFireSound = new Sound();
gBounceSound = new Sound();
gAttachSound = new Sound();
gBonusSound = new Sound();
gPopSound = new Sound();
gLostBubbleSound = new Sound();
gNextLevelSound = new Sound();
gGameOverSound = new Sound();
gCeilingSound = new Sound();
gIntroSound = new Sound(_root.intro_sound_MC);
gIntroSound.attachSound("intro_sound");
gIntroSound.start(0,30000);
gNewBubbleSpeedDefault = 350;
gNewBubbleSpeedSlow = 150;
gPopping = 0;
}
function skipLevelKeyUp(vObj)
{
var val = Number(vObj.input);
if(isNaN(val))
{
vObj.input = "";
}
else if(val < 1)
{
vObj.input = "";
}
else
{
vObj.input = Math.floor(val);
if(allowFixedLevels())
{
gRandomLevels.val = 0;
_root["option_" + gRandomLevels.pID].gotoAndStop(1);
}
else
{
gRandomLevels.val = 1;
_root["option_" + gRandomLevels.pID].gotoAndStop(2);
}
}
checkEligible();
}
function allowFixedLevels()
{
var lVal = _root.choose_level_MC.input;
if(lVal == "" || isNaN(Number(lVal)))
{
lVal = 1;
}
var lLevel = Number(lVal);
if(lLevel >= gLevelData.length)
{
return false;
}
return true;
}
function pressedRadioButton(vObj)
{
if(gOption[vObj.pID] == gHighScoreEligible && gOption[vObj.pID].val == 1)
{
return undefined;
}
var lCurrentSelection = gOption[vObj.pID].val + 1;
vObj.gotoAndStop(3 - lCurrentSelection);
}
function draggedOut(vObj)
{
if(gOption[vObj.pID] == gHighScoreEligible && gOption[vObj.pID].val == 1)
{
return undefined;
}
var lCurrentSelection = gOption[vObj.pID].val + 1;
vObj.gotoAndStop(lCurrentSelection);
}
function draggedOver(vObj)
{
if(gOption[vObj.pID] == gHighScoreEligible && gOption[vObj.pID].val == 1)
{
return undefined;
}
var lCurrentSelection = gOption[vObj.pID].val + 1;
vObj.gotoAndStop(3 - lCurrentSelection);
}
function releasedRadioButton(vObj)
{
gOption[vObj.pID].val = 1 - gOption[vObj.pID].val;
vObj.gotoAndStop(gOption[vObj.pID].val + 1);
if(gOption[vObj.pID] == gHighScoreEligible)
{
if(gHighScoreEligible.val == 1)
{
var i = 0;
while(i < gOption.length)
{
if(gOption[i] != gHighScoreEligible)
{
gOption[i].val = gDefaultOption[i];
_root["option_" + i].gotoAndStop(gDefaultOption[i] + 1);
}
i++;
}
_root.choose_level_MC.input = "";
}
else
{
gOption[vObj.pID].val = 1 - gOption[vObj.pID].val;
vObj.gotoAndStop(gOption[vObj.pID].val + 1);
}
}
else
{
if(gOption[vObj.pID] == gRandomLevels)
{
var lFixedOK = allowFixedLevels();
if(!lFixedOK && !gRandomLevels.val)
{
gRandomLevels.val = 1;
vObj.gotoAndStop(2);
}
}
checkEligible();
}
}
function checkEligible()
{
var ok = 1;
var i = 0;
while(i < gOption.length)
{
if(gOption[i] != gHighScoreEligible)
{
if(gOption[i].val != gDefaultOption[i])
{
ok = 0;
}
}
i++;
}
if(1 < Number(_root.choose_level_MC.input))
{
ok = 0;
}
gHighScoreEligible.val = ok;
_root["option_" + gHighScoreEligible.pID].gotoAndStop(ok + 1);
}
function beginLevel()
{
gNextLevelSound.attachSound("next_level_sound");
gNextLevelSound.start();
}
function startGame()
{
var lLevel = Number(_root.choose_level_MC.input);
if(!isNaN(lLevel) && lLevel >= 1)
{
gLevel = Math.floor(lLevel);
}
gotoAndStop(3);
}
function levelBubbleDone()
{
gMode = cNORMAL;
_root.level_bubble.gotoAndStop(1);
_root.level_bubble.bubble.gotoAndStop("showtext");
_root.level_bubble.bubble.bubble.graphic.gotoAndStop(1);
gotoAndStop(6);
}
function popLevelBubble()
{
_root.level_bubble.bubble.bubble.graphic.gotoAndPlay("pop");
_root.level_bubble.bubble.gotoAndStop("hidetext");
gPopSound.attachSound("pop_sound");
gPopSound.start();
}
function setUp()
{
gIntroSound.stop();
if(gMode == cSTARTGAME)
{
gNewBubbleStartX = _root.new_bubble._x;
gNewBubbleStartY = _root.new_bubble._y;
gStartingOrigin = {x:_root.bubble_MCA._x,y:_root.bubble_MCA._y};
if(!gRandomLevels.val)
{
gNumLevels = gLevelData.length;
}
else
{
gNumLevels = 0;
}
}
if(!gRandomLevels.val)
{
gData = gLevelData[gLevel].split(".");
}
_root.level_bubble.bubble.level_display = "Level\r" + gLevel;
var lLevelColor = 1 + (gLevel - 1) % 4;
_root.level_bubble.bubble.bubble.gotoAndStop(lLevelColor);
gMode = cSTARTLEVEL;
_root.controls.gotoAndStop(gUseKeyboard.val + 1);
_root.warning_message.gotoAndStop(gHighScoreEligible.val + 1);
_root.score_display = scorecheck;
Mouse.hide();
if(gDebug)
{
Mouse.show();
}
_root.level_display = gLevel;
gOrigin = {x:gStartingOrigin.x,y:gStartingOrigin.y};
_root.bubble_MCA._x = gOrigin.x;
_root.bubble_MCA._y = gOrigin.y;
_root.ceiling._y = _root.bubble_MCA._y - gSpacing / 2;
_root.frame_shadow.gotoAndStop("hide");
gCeilingRow = 0;
gCeilingY = 0;
if(gAutomatic.val)
{
gNewBubbleSpeed = gNewBubbleSpeedSlow;
}
else
{
gNewBubbleSpeed = gNewBubbleSpeedDefault;
}
if(gLevel < 6)
{
gCeilingDelay = 25000 * Math.pow(0.95,gLevel - 1);
}
else if(gLevel < 11)
{
gCeilingDelay = 25000 * Math.pow(0.95,gLevel + 5);
}
else if(gLevel < 16)
{
gCeilingDelay = 25000 * Math.pow(0.95,gLevel + 7);
}
else
{
gCeilingDelay = 25000 * Math.pow(0.95,gLevel + 8);
}
if(gDebug)
{
gCeilingDelay = 9000000;
}
if(gLevel < 13)
{
var lBonusFreq = 2 + Math.floor((gLevel - 1) / 3);
}
else if(gLevel < 20)
{
var lBonusFreq = 6;
}
else
{
var lBonusFreq = 7;
}
gHaveBonus = new Array();
var i = 0;
while(i < 10)
{
if(i < lBonusFreq)
{
gHaveBonus.push(1);
}
else
{
gHaveBonus.push(0);
}
i++;
}
gWhichBonus = new Array();
if(gLevel < 5)
{
gWhichBonus = [2,2,3,3];
}
else if(gLevel < 9)
{
gWhichBonus = [2,2,3,3,4];
}
else if(gLevel < 13)
{
gWhichBonus = [2,3,3,4,4,5];
}
else if(glevel < 17)
{
gWhichBonus = [2,3,4,4,5,5];
}
else if(glevel < 21)
{
gWhichBonus = [3,4,4,5,5];
}
else if(gLevel < 25)
{
gWhichBonus = [3,4,5,5];
}
else if(gLevel < 29)
{
gWhichBonus = [3,4,5,5,5];
}
else
{
gWhichBonus = [4,5,5,5];
}
gHaveBonusSource = gHaveBonus.slice(0);
gWhichBonusSource = gWhichBonus.slice(0);
gCeilingTimer = getTimer();
gGunTimer = getTimer();
gBubbleLevel = 1;
gBubbleList = new Array();
gBubbleRow = new Array();
gBubbleCount = [0,0,0,0,0];
gBubble = new Array();
gNumRows = 30;
gRowLength = 13;
if(gRandomLevels.val)
{
gStartRows = 3;
}
else
{
gStartRows = gData.length;
}
var lInitialBonus = [1,1,2,2,3,3,4,4];
gNumCols = gRowLength + gNumRows;
var i = 0;
while(i < gNumRows)
{
gBubble[i] = new Array();
gBubbleRow[i] = new Array();
if(i < gStartRows)
{
var lStartCol = Math.ceil(i / 2);
var lEndCol = lStartCol + gRowLength - 1;
var lDataCol = 0;
var j = lStartCol;
while(lEndCol >= j)
{
if(gRandomLevels.val)
{
if(lInitialBonus.length == 0)
{
trace("no bonuses left");
var lBonus = 1;
var lType = Math.ceil(Math.random() * 4);
}
else
{
trace("bonuses remain");
var lBonus = randomBonus(0.2);
if(lBonus == 1)
{
var lType = Math.ceil(Math.random() * 4);
}
else
{
var lIndex = Math.floor(Math.random() * lInitialBonus.length);
var lType = lInitialBonus[lIndex];
lInitialBonus.splice(lIndex,1);
}
}
}
else
{
var lCode = gData[i].charAt(lDataCol);
var lType = Number(lCode);
var lBonus = 1;
if(isNaN(lType))
{
var lNum = lCode.charCodeAt(0);
lType = (lNum - 65) % 4 + 1;
var lBonus = Math.floor((lNum - 65) / 4) + 2;
}
}
if(lType)
{
var lName = "bubble_" + i + "_" + j;
_root.bubble_MCA.attachMovie("bubble",lName,gBubbleLevel++);
var b = _root.bubble_MCA[lName];
b.pRow = i;
b.pCol = j;
if(gDebug)
{
b.bubble.position_display = "" + i + "," + j;
}
placeBubble(b);
b.bubble.gotoAndStop(lType);
b.bubble.graphic.bonus.gotoAndStop(lBonus);
gBubble[i][j] = b;
gBubbleList.push(b);
gBubbleRow[i].push(b);
gBubbleCount[lType]++;
}
lDataCol++;
j++;
}
}
i++;
}
gTopLevel = 1000;
gFutureType = Math.ceil(Math.random() * gNumTypes);
gFutureBonus = 1;
gNextType = Math.ceil(Math.random() * gNumTypes);
gNextBonus = 1;
gCurrentType = Math.ceil(Math.random() * gNumTypes);
gCurrentBonus = 1;
_root.projectile._x = _root.gun._x;
_root.projectile._y = _root.gun._y;
_root.new_bubble._x = gNewBubbleStartX;
_root.new_bubble._y = gNewBubbleStartY;
gNewBubbleMode = cSTART;
_root.future_bubble.gotoAndStop(1);
if(gDebug)
{
gNextType = 4;
gCurrentType = 4;
}
_root.projectile.bubble.gotoAndStop(gCurrentType);
_root.projectile.bubble.graphic.bonus.gotoAndStop(gCurrentBonus);
_root.new_bubble.bubble.gotoAndStop(gNextType);
_root.new_bubble.bubble.graphic.bonus.gotoAndStop(gNextBonus);
_root.future_bubble.bubble.gotoAndStop(gFutureType);
_root.future_bubble.bubble.graphic.bonus.gotoAndStop(gFutureBonus);
gRecentType = [gCurrentType,gNextType,gFutureType];
}
function randomType()
{
var lTypeChoice = new Array();
var k = 1;
while(gNumTypes >= k)
{
if(0 < gBubbleCount[k])
{
lTypeChoice.push(k);
}
k++;
}
if(lTypeChoice.length < 2)
{
return lTypeChoice[0];
}
var lCount = [0,0,0,0,0];
var i = 0;
while(i < gRecentType.length)
{
lCount[gRecentType[i]]++;
i++;
}
var lProb = new Array();
var lTotal = 0;
var i = 1;
while(4 >= i)
{
lProb[i] = gRecentType.length - lCount[i];
if(getOne(lTypeChoice,i) == -1)
{
lProb[i] = 0;
}
lTotal += lProb[i];
i++;
}
var i = 1;
while(4 >= i)
{
lProb[i] /= lTotal;
i++;
}
var n = Math.random();
var p = 0;
var i = 1;
while(4 >= i)
{
p += lProb[i];
if(n < p)
{
gRecentType.push(i);
if(gNumRecentTypes < gRecentType.length)
{
gRecentType.shift();
}
return i;
}
i++;
}
var lIndex = Math.floor(Math.random() * lTypeChoice.length);
gRecentType.push(lTypeChoice[lIndex]);
if(gNumRecentTypes < gRecentType.length)
{
gRecentType.shift();
}
return lTypeChoice[lIndex];
}
function randomBonus(vProb)
{
if(Math.random() >= vProb)
{
var lBonus = 0;
}
else
{
var lBonus = 1;
}
if(lBonus)
{
lBonus = Math.ceil(Math.random() * 4 + 1);
}
else
{
lBonus = 1;
}
return lBonus;
}
function chooseBonus()
{
if(gHaveBonusSource.length == 0)
{
gHaveBonusSource = gHaveBonus.slice(0);
}
var i = Math.floor(Math.random() * gHaveBonusSource.length);
var h = gHaveBonusSource[i];
gHaveBonusSource.splice(i,1);
if(h == 0)
{
return 1;
}
if(gWhichBonusSource.length == 0)
{
gWhichBonusSource = gWhichBonus.slice(0);
}
var i = Math.floor(Math.random() * gWhichBonusSource.length);
var b = gWhichBonusSource[i];
gWhichBonusSource.splice(i,1);
return b;
}
function onStage(r, c)
{
var lLoc = gridToPixels(r,c);
if(lLoc.x < _root.wall_left._x + gSpacing / 2)
{
return false;
}
if(_root.wall_right._x - gSpacing / 2 < lLoc.x)
{
return false;
}
if(lLoc.y < _root.wall_top._y + gSpacing / 2)
{
return false;
}
return true;
}
function placeBubble(vBubble)
{
vBubble._x = vBubble.pRow * gRdX + vBubble.pCol * gCdX;
vBubble._y = vBubble.pRow * gRdY + vBubble.pCol * gCdY;
}
function gridToPixels(r, c)
{
var x0 = r * gRdX + c * gCdX + _root.bubble_MCA._x;
var y0 = r * gRdY + c * gCdY + _root.bubble_MCA._y;
return {x:x0,y:y0};
}
function checkKeyboard(vTime)
{
var lTurning = false;
if(gUseKeyboard.val)
{
if(Key.isDown(37))
{
if(Key.isDown(Key.SHIFT))
{
turnGun(-1);
}
else
{
turnGunTimed(-5,vTime);
lTurning = true;
gGunTimer = vTime;
}
}
if(Key.isDown(39))
{
if(Key.isDown(Key.SHIFT))
{
turnGun(1);
}
else
{
turnGunTimed(5,vTime);
lTurning = true;
gGunTimer = vTime;
}
}
}
if(!lTurning)
{
gGunTimer = 0;
}
if(gMode != cNORMAL)
{
return undefined;
}
if(gUseKeyboard.val && Key.isDown(32) || gAutomatic.val)
{
fireProjectile();
}
}
function turnGunTimed(vAngle, vTime)
{
if(gGunTimer)
{
vAngle *= (vTime - gGunTimer) / 62;
}
vAngle *= 0.017453292519943295;
if(20 < vAngle)
{
vAngle = 20;
}
else if(vAngle < -20)
{
vAngle = -20;
}
var a = (_root.gun.barrel._rotation - 90) * 3.141592653589793 / 180;
a += vAngle;
if(-0.1 < a)
{
a = -0.1;
}
if(a < -3.041592653589793)
{
a = -3.041592653589793;
}
_root.gun.barrel._rotation = 90 + a * 180 / 3.141592653589793;
_root.angle_display = a;
_root.gun.barrel.pAngle = a;
_root.gun.barrel.pOldAngle = a;
}
function turnGun(vAngle)
{
vAngle *= 0.017453292519943295;
var a = (_root.gun.barrel._rotation - 90) * 3.141592653589793 / 180;
a += vAngle;
if(-0.1 < a)
{
a = -0.1;
}
if(a < -3.041592653589793)
{
a = -3.041592653589793;
}
_root.gun.barrel._rotation = 90 + a * 180 / 3.141592653589793;
_root.angle_display = a;
_root.gun.barrel.pAngle = a;
_root.gun.barrel.pOldAngle = a;
}
function newBubbleDone()
{
_root.new_bubble._x = _root.gun._x;
_root.new_bubble._y = _root.gun._y;
gNewBubbleMode = cFINISH;
if(gProjectileWaiting)
{
_root.projectile._x = _root.gun._x;
_root.projectile._y = _root.gun._y;
gProjectileWaiting = false;
}
}
function frameLoop()
{
if(gFrameTimer == -1)
{
gFrameTimer = getTimer();
gCeilingTimer = getTimer();
}
var lTime = getTimer();
checkKeyboard(lTime);
if(gMode == cSTARTGAME || gMode == cSTARTLEVEL)
{
return undefined;
}
moveGun(lTime);
moveNewBubble(lTime);
if(gMode == cFIRE || gMode == cCONTACT || gMode == cREMOVE)
{
moveProjectile(lTime);
}
else if(gMode == cCEILING)
{
updateCeiling(lTime);
}
else if(gMode == cNORMAL)
{
checkCeiling(lTime);
}
else if(gMode == cDIE)
{
var n = gBubbleList.length;
if(n == 0 && lTime >= gDieTimer + gDieDuration)
{
_root.gun.barrel._rotation = 0;
if(gHighScoreEligible.val)
{
_root.submit_score_MC.gotoAndStop("show");
}
else
{
_root.submit_score_MC.gotoAndStop("hide");
}
Mouse.show();
gotoAndStop(11);
}
else if(0 < n)
{
var b = gBubbleList.pop();
b.bubble.graphic.bonus.gotoAndStop(1);
b.bubble.graphic.gotoAndPlay("pop");
gPopSound.attachSound("pop_sound");
gPopSound.start();
}
}
gFrameTimer = lTime;
}
function moveGun(vTime)
{
if(!gMoveGun.val)
{
return undefined;
}
if(gMode != cNORMAL && gMode != cFIRE)
{
return undefined;
}
var x = _root.gun._x;
var w = 2 * gGunLength;
x += gGunDir * (vTime - gFrameTimer) * gGunSpeed / 1000;
if(x >= _root.wall_right._x - w / 2)
{
x = _root.wall_right._x - w / 2;
gGunDir *= -1;
}
else if(_root.wall_left._x + w / 2 >= x)
{
x = _root.wall_left._x + w / 2;
gGunDir *= -1;
}
if(_root.new_bubble._x == _root.gun._x)
{
_root.new_bubble._x = x;
}
_root.gun._x = x;
_root.tubing_main._xscale = (_root.gun._x - _root.tubing_1._x - 20) * 100 / 165;
if(_root.projectile._y == _root.gun._y)
{
_root.projectile._x = _root.gun._x;
}
}
function moveNewBubble(vTime)
{
if(gNewBubbleMode != cMOVE)
{
return undefined;
}
var lDist = (vTime - gFrameTimer) * gNewBubbleSpeed / 1000;
var x = _root.new_bubble._x;
var y = _root.new_bubble._y;
if(y < _root.tubing_main._y && x == _root.tubing_1._x)
{
y += lDist;
if(y >= _root.tubing_main._y)
{
y = _root.tubing_main._y;
}
}
else if(y == _root.tubing_main._y && x != _root.gun._x)
{
x += lDist;
if(x >= _root.gun._x)
{
x = _root.gun._x;
}
}
else
{
y -= lDist;
if(_root.gun._y >= y)
{
y = _root.gun._y;
gNewBubbleMode = cFINISH;
newBubbleDone();
}
}
_root.new_bubble._x = x;
_root.new_bubble._y = y;
}
function updateCeiling(vTime)
{
_root.frame_shadow.gotoAndStop("show");
var y = _root.ceiling._y;
y += 3;
var lDestY = _root.wall_top._y + gCeilingY;
if(y >= lDestY)
{
y = lDestY;
gOrigin = {x:_root.bubble_MCA._x,y:_root.bubble_MCA._y};
gMode = cNORMAL;
}
_root.ceiling._y = y;
_root.bubble_MCA._y = y + gSpacing / 2;
if(gMode == cNORMAL)
{
checkDie();
}
}
function checkDie()
{
if(gCeilingRow == 13)
{
startDie();
return true;
}
var i = 0;
while(i < gBubbleRow.length)
{
if(0 >= gBubbleRow[i].length)
{
return false;
}
if(i + gCeilingRow >= 13)
{
startDie();
return true;
}
i++;
}
}
function startDie()
{
gMode = cDIE;
gDieTimer = getTimer();
}
function checkCeiling(vTime)
{
if(gCeilingTimer + gCeilingDelay < vTime)
{
gCeilingSound.attachSound("ceiling_sound");
gCeilingSound.start();
gMode = cCEILING;
gCeilingRow++;
gCeilingY = gCeilingRow * gRdY;
gCeilingTimer = vTime;
}
}
function popDone(vBubbleGraphic)
{
var lBubble = vBubbleGraphic._parent._parent;
if(lBubble._parent == _root.level_bubble)
{
return undefined;
}
lBubble.removeMovieClip();
gPopping--;
}
function normalizeDirChange(vChange)
{
if(Math.abs(vChange) == 3)
{
return 0;
}
if(vChange < -2)
{
return vChange + 6;
}
if(2 < vChange)
{
return vChange - 6;
}
return vChange;
}
function gridToDir(dr, dc)
{
var lDir = -1;
if(dr == -1)
{
if(dc == -1)
{
lDir = 4;
}
else if(dc == 0)
{
lDir = 5;
}
}
else if(dr == 0)
{
if(dc == -1)
{
lDir = 3;
}
else if(dc == 1)
{
lDir = 0;
}
}
else if(dr == 1)
{
if(dc == 0)
{
lDir = 2;
}
else if(dc == 1)
{
lDir = 1;
}
}
return lDir;
}
function turnDir(vDir, vChange)
{
var lNewDir = vDir + vChange;
if(5 < lNewDir)
{
lNewDir -= 6;
}
else if(lNewDir < 0)
{
lNewDir += 6;
}
return lNewDir;
}
function sortByPositionDist(vPos1, vPos2)
{
var lGridPos1 = getNeighborPos(gTarget,vPos1);
var lLoc1 = gridToPixels(lGridPos1.r,lGridPos1.c);
var lDist1 = pointDist(lLoc1,gTangentPosition);
var lGridPos2 = getNeighborPos(gTarget,vPos2);
var lLoc2 = gridToPixels(lGridPos2.r,lGridPos2.c);
var lDist2 = pointDist(lLoc2,gTangentPosition);
if(lDist2 < lDist1)
{
return 1;
}
if(lDist1 < lDist2)
{
return -1;
}
return 0;
}
function pointDist(p1, p2)
{
var dx = p1.x - p2.x;
var dy = p1.y - p2.y;
return Math.sqrt(dx * dx + dy * dy);
}
function dirToGrid(vIndex)
{
if(vIndex == 0 || vIndex == 1)
{
dc0 = 1;
}
else if(vIndex == 3 || vIndex == 4)
{
dc0 = -1;
}
else
{
dc0 = 0;
}
if(vIndex == 1 || vIndex == 2)
{
dr0 = 1;
}
else if(vIndex == 4 || vIndex == 5)
{
dr0 = -1;
}
else
{
dr0 = 0;
}
return {dr:dr0,dc:dc0};
}
function getNeighborPos(vObj, vIndex)
{
var r0 = vObj.pRow;
var c0 = vObj.pCol;
if(vIndex == 0 || vIndex == 1)
{
c0 += 1;
}
else if(vIndex == 3 || vIndex == 4)
{
c0 -= 1;
}
if(vIndex == 1 || vIndex == 2)
{
r0 += 1;
}
else if(vIndex == 4 || vIndex == 5)
{
r0 -= 1;
}
return {r:r0,c:c0};
}
function getBubbleAt(r, c)
{
if(r < 0 || c < 0)
{
return -1;
}
if(Math.ceil(r / 2) + gRowLength - 1 < c)
{
return -1;
}
if(c < Math.ceil(r / 2))
{
return -1;
}
var b = gBubble[r][c];
if(b == undefined)
{
return 0;
}
return b;
}
function getOne(array, x)
{
var i = 0;
while(i < array.length)
{
if(x == array[i])
{
return i;
}
i++;
}
return -1;
}
function reflect(vAngle1, vAngle2)
{
var lRemapAngle1 = remapAngle(vAngle1,vAngle2);
if(1.5707963267948966 < Math.abs(lRemapAngle1))
{
vAngle2 += 3.141592653589793;
vAngle2 = normalizeAngle(vAngle2);
}
var lDiff = remapAngle(vAngle1,vAngle2);
vAngle1 -= 2 * lDiff;
vAngle1 = normalizeAngle(vAngle1);
return vAngle1;
}
function updateScore(vChange)
{
score += vChange;
scorecheck = String(Number(scorecheck) + vChange);
_root.score_display = scorecheck;
}
function levelOver()
{
gLevel++;
if(gLevel >= gNumLevels)
{
gRandomLevels.val = true;
}
gotoAndStop(3);
}
function playAgain()
{
_root.gotoAndStop("intro");
}
function submitScore()
{
extra += "Level " + gLevel;
stats += "";
loadMovie("game.swf?score=" + score + "&scorecheck=" + scorecheck + "&extra=" + extra + "&stats=" + stats + "&scoremode=" + scoremode + "&gamename=" + gamename + "&textname=" + textname,_root);
}
function dist(x0, y0, x1, y1)
{
var dx = x0 - x1;
var dy = y0 - y1;
return Math.sqrt(dx * dx + dy * dy);
}
function pixelsToPos(vHubX, vHubY, vLocX, vLocY)
{
var dx = vLocX - vHubX;
var dy = vLocY - vHubY;
var a = Math.atan2(dy,dx);
if(a < 0)
{
var lPos = 3 + (a + 3.141592653589793) * 3 / 3.141592653589793;
}
else
{
var lPos = a * 3 / 3.141592653589793;
}
return lPos;
}
stop();